package com.example.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * <p> AspectJ 测试 </p>
 *
 * @author Chris
 * @since 2022/9/20 15:47
 */
@Aspect
public class LogAop {

    @Pointcut("execution(* com..*.test(..))")
    public void test() {

    }

    @Before("test()")
    public void beforeTest() {
        System.out.println("before");
    }

    @After("test()")
    public void afterTest() {
        System.out.println("after");
    }

    @Around("test()")
    public Object aroundTest(ProceedingJoinPoint p) throws Throwable {
        System.out.println("around before:" + p);
        final Object proceed = p.proceed();
        System.out.println("around after:" + p);
        return proceed;
    }

}